home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 08 - 1992 / 08.04 Aug 92 / Hello TCL World / TextWindow.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-20  |  2.9 KB  |  128 lines  |  [TEXT/KAHL]

  1. /*                        TextWindow.c                    */
  2. /*
  3.  * TextWindow
  4.  *    Superclass: CDirector.
  5.  * Copyright © 1991 Martin Minow. All Rights Reserved.
  6.  * All use and non-commercial distribution permitted.
  7.  * Set tabs every 4 bytes.
  8.  *
  9.  * This is a very simple text-only, output-only, display
  10.  * window. It intentionally does not support cut/paste,
  11.  * filing and printing.  It is based on the design of
  12.  * the TCL CClipboard class.  In fact, if I was cleverer,
  13.  * I'd make this a sub-class of CClipboard.
  14.  */
  15.  
  16. #ifdef DOCUMENTATION
  17.  
  18. title        TextWindow
  19. superclass    CDirector
  20. subclasses    none
  21.  
  22. usage
  23.  
  24.     #include    "TextWindow.h"
  25.     
  26.     void                    ITextWindow(
  27.         CApplication    *aSupervisor,
  28.         short            aWindowId,
  29.         Boolean            isFloating,
  30.         Boolean            hideOnSuspend,
  31.         long            toggleCmd,
  32.         short            showHideRes,
  33.         StringPtr        fontName,
  34.         short            fontSize
  35.     );
  36.         Initialization.  itsSupervisor must be the
  37.         application.  It displays the window defined
  38.         by aWindowId. Text is written in the indicated
  39.         font and size.  The toggleCmd and showHideRes
  40.         parameters are described in the AuxWindow class.
  41.         
  42.     void                    Dispose(void);
  43.         Dispose of the window and its contents.
  44.         
  45.     void                    SetText(
  46.         StringPtr        someText
  47.     );
  48.         Put a line of text on the screen.
  49.         It rolls text up the display.
  50.     
  51.     StringHandle            GetText(
  52.         short            index
  53.     );
  54.         Get the StringHandle for the specified line.    
  55.     
  56. author
  57.     Martin Minow
  58.  
  59. copyright
  60.     Copyright © 1991 Martin Minow. All Rights Reserved.
  61.     Non-commercial use and distribution permitted.
  62.     
  63. #endif
  64.  
  65. #include <CBureaucrat.h>
  66. #include <CDecorator.h>
  67. #include <CTextEnvirons.h>
  68. #include <TBUtilities.h>
  69. #include "TextWindow.h"
  70.  
  71. extern CBureaucrat        *gGopher;
  72. extern CDecorator        *gDecorator;
  73.  
  74. #define itsTextInfo        ((CTextEnvirons *) itsEnvironment)
  75.  
  76. /*
  77.  * Initialize the TextWindow.
  78.  */
  79. void
  80. TextWindow::ITextWindow(
  81.         CApplication    *aSupervisor,    /* The app.        */
  82.         short            aWindowId,        /* WIND res.    */
  83.         Boolean            isFloating,        /* Floating?    */
  84.         Boolean            hideOnSuspend,    /* Mac-like?    */
  85.         long            toggleCmd,        /* Show/hide it    */
  86.         short            showHideRes,    /* STR# text    */
  87.         StringPtr        fontName,        /* Font name    */
  88.         short            fontSize        /* Font size    */
  89.     )
  90. {
  91.         Rect                    windowBox;
  92.         
  93.         AuxWindow::IAuxWindow(        /* Init superclass    */
  94.             aSupervisor,            /* Supervisor        */
  95.             aWindowId,                /* Enclosure        */
  96.             isFloating,                /* Does it float?    */
  97.             hideOnSuspend,            /* Mac-like?        */
  98.             toggleCmd,                /* Our command        */
  99.             showHideRes                /* Menu text STR#    */
  100.         );
  101.         gDecorator->CenterWindow(itsWindow);
  102.         itsWindow->GetAperture(&windowBox);
  103.         itsTextPane = new(TextPane);
  104.         itsTextPane->ITextPane(
  105.             itsWindow,            /* Enclosure                */
  106.             this,                /* Enclosure                */
  107.             windowBox.right - windowBox.left, /* Width    */
  108.             windowBox.bottom - windowBox.top, /* Height    */
  109.             0, 0,                /* Offset in enclosure    */
  110.             sizFIXEDLEFT, sizFIXEDTOP,
  111.             fontName,
  112.             fontSize
  113.         );
  114. }
  115.  
  116. /*
  117.  * The SetText method adds text to the data pane.
  118.  */
  119. void
  120. TextWindow::SetText(
  121.         StringPtr        someText
  122.     )
  123. {
  124.         itsTextPane->SetText(someText);
  125. }
  126.  
  127.  
  128.